package main

import (
	"fmt"
	"sync"
	"time"
)

var TestTimeTickMap sync.Map

func main() {
	for i := 0; i < 150000; i++ {
		go TickTest(time.Second * 8)
	}
	//go TestMap()
	//go TestMap2()
	time.Sleep(time.Second * 10)
}

func TickTest(duration time.Duration) {
	timer := time.NewTimer(duration)
	defer timer.Stop()
	t := time.NewTicker(time.Second * 1)
	var index = 0
	for {
		select {
		case <-timer.C:
			fmt.Println("Time out!")
			//todo
			return
		case <-t.C:
			index++
		}
	}
}

func TestMap() {
	//time.Sleep(time.Second * 5)
	TestTimeTickMap.Store(1, make(chan struct{}))
}
func TestMap2() {
	TestTimeTickMap.Store(2, make(chan struct{}))
}
